import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
const routes = [
  {
    path: '/',
    redirect: '/echart' // 重定向
  },
  {
    path: '/echart',
    component: () => import('../views/echart/index.vue'),
    redirect: '/echart/bar',
    children: [
      {
        path: 'bar',
        component: () => import('@/views/echart/bar/bar.vue'),
      },
      {
        path: 'line',
        component: () => import('@/views/echart/line/line.vue'),
      },
      {
        path: 'pie',
        component: () => import('@/views/echart/pie/pie.vue'),
      },
      {
        path: 'radar',
        component: () => import('@/views/echart/radar/radar.vue'),
      },
      {
        path: 'map',
        component: () => import('@/views/echart/map/map.vue'),
      }
    ]
  }
]
const router = new VueRouter({
  routes
})
export default router
